home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / index.arc / AEBITNEX.BAS < prev    next >
BASIC Source File  |  1987-01-21  |  1KB  |  75 lines

  1. rem $linesize:132
  2. rem $title:'Application Engineer Standard Routines'
  3. rem $subtitle:'Find the NEXT key in lexical sequence.'
  4.  
  5. '
  6. '  this routine will return the next key in the index from the current
  7. '  one. if there are no current values for the key, then a negative
  8. '  value will be returned, else a positive value indicating the records -
  9. '  master and index - will be returned (or a zero if no next key).
  10. '
  11. '
  12. '  Have it do better on ends of chains.
  13. '
  14. '                Include the COMMON values
  15. '
  16. rem $include:'AESHARED.BAS'
  17.     
  18. sub bit.next(fl%,ky$,mrec%,success%) static
  19.  
  20.         pky$=ky$
  21.         pmrec%=mrec%
  22.         psuccess%=success%
  23.  
  24.         tvalue%=success%
  25.         if success%=0 then
  26.             goto nonext
  27.         end if
  28.         get #fl%,success%
  29.         tkey$=xk$(fl%,1)
  30.  
  31.         rght%=cvi(xk$(fl%,3))
  32.         if rght%=0 then
  33.             goto header
  34.         end if
  35.         success%=rght%
  36.  
  37. mleft:
  38.         get #fl%,success%
  39.         lft%=cvi(xk$(fl%,2))
  40.         if lft%=0 then
  41.             goto nhere
  42.         end if
  43.         success%=lft%
  44.         goto mleft
  45.  
  46. header:
  47.         parent%=cvi(xk$(fl%,4))
  48.         if parent%=0 then
  49.             goto nonext
  50.         end if
  51.         success%=parent%
  52.         get #fl%,success%
  53.         if xk$(fl%,1)>tkey$ then
  54.             goto nhere
  55.         end if
  56.         goto header
  57. nhere:
  58.         mrec%=cvi(xk$(fl%,5))
  59.         ky$=xk$(fl%,1)
  60.         goto fnext
  61. nonext:
  62.         ky$=""
  63.         mrec%=0
  64.         success%=0
  65. fnext:
  66.         if success%=0% or mrec%=0% then
  67.             if pmrec%>0% and psuccess%>0% then
  68.                 ky$=pky$
  69.                 mrec%=pmrec%
  70.                 success%=psuccess%
  71.             end if
  72.         end if
  73.  
  74.     end sub
  75.